package com.example.demo.demos.web.Controller;

import com.example.demo.demos.web.Services.UserLoginService;
import com.example.demo.demos.web.po.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.*;

/**
 * @BelongsProject: demo1
 * @BelongsPackage: com.example.demo.demos.web.Controller
 * @Author: Hu1er
 * @CreateTime: 2023-06-28  12:42
 * @Description: TODO
 * @Version: 1.0
 */

@Controller
public class LoginController {
    @Autowired
    private UserLoginService userLoginService;

    /**
     * @Description 登录控制器
     * @author Hu1er
     * @version 1.17.0
     * @date 2023/6/28
     */
    @PostMapping("/login")
    @ResponseBody
    public String Login(User user){
        if (userLoginService.login(user)){
            return "hello:"+user.getUsername();
        }else {
            return "用户或密码错误！";
        }
    }

}
